<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class A_non_sy extends CI_Controller {

	function __construct() {
        parent::__construct();	
		$this->load->model("master/master_j_pendidikan"); 
		$this->load->model("atur/atur_non_syahriyah"); 
	}
	
	function index()
	{
		$data['judul'] = "Pengaturan Tagihan Non Syahriyah";
		$data['list'] = $this->master_j_pendidikan->read();
		$data['main_view']='atur/non_syahriyah/jenjang';
		$this->load->view('index',$data);		
	}
	
	function non_sy($id_m_j_pendidikan)
	{
		$data['judul'] = "Pengaturan Tagihan Non Syahriyah";
		$data['list']=$this->atur_non_syahriyah->non_sy($id_m_j_pendidikan);	
		$data['list_jp']=$this->master_j_pendidikan->detail($id_m_j_pendidikan);
				
		$data['main_view']='atur/non_syahriyah/non_sy';
		$this->load->view('index',$data);
	}
	
	function save()
	{
		$mulai_bayar = $this->input->post('mulai_bayar');
		$dateMulai = str_replace('/', '-', $mulai_bayar);
		$tglMySQLM = date('Y-m-d', strtotime($dateMulai));

		$akhir_bayar = $this->input->post('akhir_bayar');
		$dateAkhir = str_replace('/', '-', $akhir_bayar);
		$tglMySQLA = date('Y-m-d', strtotime($dateAkhir));

		$dataInsert = array(
			'nama_non_sy' => $this->input->post('nama_non_sy'),
			'besar_bayar' => $this->input->post('besar_bayar'),
			'mulai_bayar' => $tglMySQLM,
			'akhir_bayar' => $tglMySQLA,
			'ket' => $this->input->post('ket'),
			'id_m_j_pendidikan' => $this->input->post('id_m_j_pendidikan')
		);
		$this->atur_non_syahriyah->save($dataInsert);
	}	
	
	function delete()
	{
		$id_a_non_sy = $this->input->post('id_a_non_sy');
		$this->atur_non_syahriyah->delete($id_a_non_sy);
	}
	
	function refresh()
	{
		$id_m_j_pendidikan = $this->security->xss_clean($this->uri->segment(3));	
		$data['list']=$this->atur_non_syahriyah->non_sy($id_m_j_pendidikan);	
		$data['list_jp']=$this->master_j_pendidikan->detail($id_m_j_pendidikan);
		$this->load->view('atur/non_syahriyah/refresh', $data);		
	}
}